﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Cangku.颜鹭
{
    public partial class Tianjia : Form
    {
        public Tianjia()
        {
            InitializeComponent();
        }
   
        private void Zhuangtai_TextChanged(object sender, EventArgs e)
        {
            if (zhuangtai.Text != "0" && zhuangtai.Text != "1")
            {
                zhuangtai.Text = "";
            }
           
        }

        private void Tianjia_Load(object sender, EventArgs e)
        {

        }

        private void Queding_btn_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new
           SqlConnection("Data Source=.;Initial Catalog=text2;Integrated Security=True");
            conn.Open();
            string bianhao_text = Console.ReadLine();
            string zhuangtai = Console.ReadLine();
            string mingchen = Console.ReadLine();
            string sql = string.Format("insert into Cangku values('{0}','{1}','{2}')",bianhao_text, zhuangtai, mingchen);
            SqlCommand command = new SqlCommand(sql, conn);
            int count = command.ExecuteNonQuery();
            if (count > 0)
            {
                MessageBox.Show("数据添加成功！");
            }
            else
            {
                MessageBox.Show("数据添加失败！");
            }
        }

        private void Quxiao_btn_Click(object sender, EventArgs e)
        {
            quxiao_btn.Text = string.Empty;
            this.Close();
        }
        static int i = 0;
        private void Bianhao_text_KeyPress(object sender, KeyPressEventArgs e)
        {
         
            if (e.KeyChar != '\b')//这是允许输入退格键

            {
                if ((e.KeyChar < '0') || (e.KeyChar > '9'))//这是允许输入0-9数字

                {
                    e.Handled = true;

                }
                else
                {
                    i++;
                    if (i > 2)
                    {
                        e.Handled = true;//不处理
                    }
                }

            }
        }

        private void quxiao_btn_KeyPress(object sender, KeyPressEventArgs e)
        {
            
        }
    }

}
